

function getoption(datajson) {
	var lines = {
			'高血压高值' : [120,140],
			'高血压低值' : [80,90],
			'心率':[60,100],
			'血糖':[3.9,6.1]
		}
	option = {
		title : {
			text : datajson.title,
			subtext : datajson.subtext
		},
		tooltip : {
			trigger : 'axis'
		},
		legend : {
			data : datajson.legend
		},
		toolbox : {
			show : true,
			feature : {
				dataZoom : {
					yAxisIndex : 'none'
				},
				dataView : {
					readOnly : false
				},
				magicType : {
					type : [ 'line', 'bar']
				},
				restore : {},
				saveAsImage : {}
			}
		},
		xAxis : {
			type : 'category',
			boundaryGap : false,
			data : datajson.xAxis
		},
		yAxis : {
			type : 'value'
		},
		optionToContent: function (opt) {
		    let axisData = opt.xAxis[0].data; //坐标数据
		    let series = opt.series; //折线图数据
		    let tdHeads = '<td  style="padding: 0 10px">时间</td>'; //表头
		    let tdBodys = ''; //数据
		    series.forEach(function (item) {
		        //组装表头
		        tdHeads += '<td style="padding: 0 10px">'+item.name+'</td>';
		    });
		    let table = '<table border="1" style="width: 90%;margin-left:20px;border-collapse:collapse;font-size:14px;text-align:center"><tbody><tr>'+tdHeads+'</tr>';
		    for (let i = 0, l = axisData.length; i < l; i++) {
		        for (let j = 0; j < series.length; j++) {
		            //组装表数据
		            tdBodys += '<td>'+series[j].data[i]+'</td>';
		        }
		        table += '<tr><td style="padding: 0 10px">'+axisData[i]+'</td>'+tdBodys+'</tr>';
		        tdBodys = '';
		    }
		    table += '</tbody></table>';
		    return table;
		}
	};
	var ser = []
	var yAxis = datajson.yAxis
	var i = 0
	for (var p in yAxis) {
		var ya = yAxis[p]
		var y = {}
		y.name = ya.title
		y.type = 'line'
		y.data = ya.yAxis
		y.markPoint = {
			data : [
				{
					type : 'max',
					name : '最大值'
				},
				{
					type : 'min',
					name : '最小值'
				}
			]
		}
		var line = []
		var j = 0
		if (ya.isAver == true) {
			line[j] = {
				type : 'average',
				name : '平均值'
			}
			j++
		}
		for(var l in lines){
			if(l == ya.title){
				var ll = lines[l]
				for(var s=0;s<ll.length;s++){
					line[j] = {yAxis:ll[s]}
					j++
				}
			}
		}
		$.each(lines, function(name, value) {
			if (name == ya.title) {
				for(k=0;k<value.length;k++){
					line[j] = {
							yAxis : value[k]
						}
					j++
				}
			}
		})
		y.markLine = {
			data : line
		}
		ser[i] = y
		i++
	}
	option.series = ser
	console.info(JSON.stringify(option))
	return option
}